package com.aqie.haikang.dorm.dao;

import com.aqie.haikang.dorm.entity.HkEnter;
import com.aqie.haikang.dorm.entity.dto.HkEnterDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author aqie
 * @Date 2021/12/11 9:37
 * @desc
 */
public interface HkEnterRepository extends JpaRepository<HkEnter, Long> {
    @Query("select new com.aqie.haikang.dorm.entity.dto.HkEnterDTO(hk.id,hk.tenantId,hk.name,hk.code,hk.buildingNum,hk.status,hk.contrastStatus,max(hk.createTime)) " +
            "from HkEnter as hk where date_format(from_unixtime(create_time/1000),'%Y-%m-%d')=date_format(now(),'%Y-%m-%d') and date_format(from_unixtime(create_time/1000),'%H:%i:%s') > '17:00:00'" +
            " group by hk.code,hk.status order by hk.createTime asc")
    List<HkEnterDTO> findCurrentAll();
}
